<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>父子组件</title>
</head>

<body>
    <div id="app">
        <my-parent></my-parent>
    </div>
</body>
<template id="parent">
    <div>
        <h1>父组件</h1>
        <my-child></my-child>
    </div>
</template>
<template id="child">
    <div>
        <h3>子组件</h3>
    </div>
</template>
<script src="lib/vue.js"></script>
<script>
    // 谁用谁注册，子组件在父组件前面声明
    const Child = {
        template: "#child"
    }
    const Parent = {
        template: "#parent",
        components: {
            MyChild: Child
        }
    }
    new Vue({
        el: "#app",
        components: {
            MyParent: Parent
        }
    })
</script>

</html>